<!---GUI FOR generation of new eDTR--->
<!---by mico--->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<TITLE>iBOS/e eDTR Manager</TITLE>
		<CFINCLUDE TEMPLATE="#client.common_path#_toggle.cfm">
		<CFOUTPUT>
			<LINK REL="StyleSheet" HREF="#client.wstheme_path##client.empcolor#.css" TYPE="text/css">
		</CFOUTPUT>
<CFINCLUDE TEMPLATE="#client.common_path#popdate.cfm">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">	
function ShowCalendar(FormName, FieldName) {
			quickpopdate(FormName, FieldName)
	}
	function ShowLookup(level, tblname, frmfldcode, formname, fld2disp, fldcode, frmflddesc, flddesc,filter) 											{
					<CFOUTPUT>
						open("#CLIENT.COMMON_PATH#poplookup.cfm" +
					</CFOUTPUT>
						"?tl=" + level +
						"&tn=" + tblname +
						"&fn=" + frmfldcode +
						"&frm=" + formname +
						"&fldprop=" + fld2disp +
						"&fldfn=" + fldcode +
						"&desc=" + frmflddesc +
						"&flddesc=" + flddesc +
						"&filter=" + filter,
						"LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes")
				}
</SCRIPT>
	</HEAD>
	<!---<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTDTR"
		USERFIELD = "USERGRPID_FK" RECORDFIELD = "EDTRCODE_FK" BOOLEANFIELDS="ISVIEW">--->
<BODY LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>
<CFOUTPUT>
<CFIF STRUCTKEYEXISTS(FORM,"btnNEWEDTR")>
	<cfset windowtitle = "Add new eDTR">
	<CFSET sAction = "addnew">
	<cfset edtrcode = "">
	<CFQUERY name="getrecord" datasource="#client.company_dsn#">
		select * from ecrgdtr
		where edtrcode = '#edtrcode#'
	</CFQUERY>
<cfelseif STRUCTKEYEXISTS(URL,"edit")>
	<cfset windowtitle = "Edit eDTR">
	<cfset EDTRCODE = decrypt(url.edit,client.ek)>
	<cfset saction = "edit">
	<CFQUERY name="getrecord" datasource="#client.company_dsn#">
		select * 
		from ecrgdtr
		where edtrcode = '#edtrcode#'
	</CFQUERY>
<cfelseif structkeyexists(url,"copy")>
	<cfset windowtitle = "Replicate eDTR">
	<cfset EDTRCODE = decrypt(url.copy,client.ek)>
	<cfset saction = "replicate">
	<CFQUERY name="getrecord" datasource="#client.company_dsn#">
		select * 
		from ecrgdtr
		where edtrcode = '#edtrcode#'
	</CFQUERY>
</CFIF>
<cfquery name="getecrgdtrfields" datasource="#client.global_dsn#">
	select columnname
	from grgbosetablefields
	where tablename = 'ecrgdtr'
</cfquery>
<cfquery name="qrycrgtkfiles" datasource="#client.company_dsn#">
	select cutoffstartdate,cutoffenddate 
	from crgtkfiles
	where tkfilename = '#getrecord.tkfilename_fk#'
</cfquery>
<cfloop query="getecrgdtrfields">
	<cfset "#columnname#" = evaluate("getrecord.#columnname#")>
</cfloop>
<cfset cutoffstart = qrycrgtkfiles.cutoffstartdate>
<cfset cutoffend = qrycrgtkfiles.cutoffenddate>
<TABLE BORDER=0 CELLSPACING=5 CELLPADDING=0 WIDTH="100%">
	<CFIF isdefined("session.sMess") and session.sMess NEQ "">
		<TR>
			<TD>
				<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Information">
				<BR><B>#session.sMess#</B><BR>
				<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
				<cfset session.sMess="">
			</TD>
		</TR>
	</CFIF>
</TABLE>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#windowtitle#">
	<CFFORM name="frmNEWEDTR" method="post" format="html" action="#getfilefrompath(getbasetemplatepath())#">
	<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="50%">
		<TR height="20"><TD></TD></TR>
		<TR><TD colspan="3"><CFINPUT type="submit" name="btnSAVENEWEDTR" value="SAVE">&nbsp;&nbsp;&nbsp;<CFINPUT type="button" name="btnCANCEL" value="CANCEL" onClick="history.back()"></TD></TR>
		<TR height="20"><TD></TD></TR>
		<TR>
			<TD>GROUP:</TD>
		  <TD><CFINPUT type="text" name="edtEDTRGROUP" id="edtEDTRGROUP">
          		<cfset temp = QueryAddRow(getEDTRGROUPS)>
                <cfset temp = QuerySetCell(getEDTRGROUPS,"EDTRGROUP","-Select-")>
			  <CFSELECT name="selGROUP" query="getEDTRGROUPS" value="EDTRGROUP" display="EDTRGROUP" queryPosition="below" selected="-Select-" onChange="edtEDTRGROUP.value=this.value;"/>
         </TD>

		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>DESCRIPTION:*</TD>
			<TD><CFINPUT type="text" NAME ="edtEDTRDESC" required="yes" validateat="onsubmit" message="Description is required" value="#edtrdesc#"></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>TK FILENAME:*</TD>
			<TD><CFINPUT name="edtTKFILENAME_FK" type="text" required="yes" message="TK Filename is required" readonly="yes" validateat="onsubmit" value="#tkfilename_fk#">
			<A HREF="javascript:ShowLookup('C','CRGTKFILES','edtTKFILENAME_FK,edtCUTOFFSTARTDATE,edtCUTOFFENDDATE','frmNEWEDTR','TKFILENAME~TKFILENAME~ftString,CUTOFFSTARTDATE~CUTOFFSTARTDATE~ftDateTime,CUTOFFENDDATE~CUTOFFENDDATE~ftDateTime','TKFILENAME','edtTKFILENAME_FK,edtCUTOFFSTARTDATE,edtCUTOFFENDDATE','TKFILENAME','')"> <IMG SRC="#CLIENT.ICON_PATH#lookup.gif" BORDER="0" ALT="Select from Lookup" ALIGN="bottom"></A></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>Attendance Start:</TD>
			<TD><CFINPUT name="edtCUTOFFSTARTDATE" type="text" readonly="YES" mask="9999-99-99" value="#cutoffstart#"></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>Attendance End:</TD>
			<TD><CFINPUT name="edtCUTOFFENDDATE" type="text" readonly="YES" mask="9999-99-99" value="#cutoffend#"></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>SHARED VIEW:</TD>
			<TD>
				<CFSELECT name="edtSHAREDVIEW">
					<OPTION value="YES"  <cfif sharedview eq "YES" or sharedview eq ""> selected="selected" </cfif> > YES </OPTION>
					<OPTION value="NO" <cfif sharedview eq "NO"> selected="selected" </cfif> > NO </OPTION>
				</CFSELECT>
			</TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>SHARED UPDATE:</TD>
			<TD>
				<CFSELECT name="edtSHAREDUPDATE">
					<OPTION value="YES" <cfif sharedupdate eq "YES" or sharedupdate eq ""> selected="selected" </cfif> > YES </OPTION>
					<OPTION value="NO" <cfif sharedupdate eq "NO"> selected="selected" </cfif> > NO </OPTION>
				</CFSELECT>
			</TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>VIEW UNTIL:</TD>
			<TD><CFINPUT type="text" name="edtVIEWUNTIL" required="yes" validateat="onsubmit" message="View Until is required." value="#viewuntil#" readonly="yes">
			<A HREF="javascript:ShowCalendar('frmNEWEDTR','edtVIEWUNTIL');"> <IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom"></A></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>UPDATE UNTIL:</TD>
			<TD><CFINPUT name="edtUPDATEUNTIL" type="text" required="yes" validateat="onsubmit" message="Update Until is required." value="#updateuntil#" readonly="yes">
			<A HREF="javascript:ShowCalendar('frmNEWEDTR','edtUPDATEUNTIL');"> <IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom"></A></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>Cut-Off Date and Time:</TD>
			<!--- Changed from cuttoff to getRecord.cutOff --->
			<TD><CFINPUT name="edtCutoffdate" type="text" required="yes" validateat="onsubmit" message="Cut-off date is required." value="#dateformat(getrecord.cutoff,"m/dd/yyy")#">
			<A HREF="javascript:ShowCalendar('frmNEWEDTR','edtCutoffdate');"> <IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom"></A>
			<CFINPUT name="edtCutofftime" type="text" required="yes" validateat="onsubmit,onserver" message="Please enter a proper value for Cut-off time." value="#timeformat(getrecord.cutoff,"HH:mm")#" mask="99:99" validate="time"></TD>
		</TR>
		<TR height="10"><TD></TD></TR>
		<TR>
			<TD>GROUPING VALUE:*</TD>
			<TD><CFINPUT name="edtGROUPCODE" type="text" required="yes" message="Grouping Value is required" readonly="yes" validateat="onsubmit" value="#groupcode#">
			<A HREF="javascript:ShowLookup('G','GRGBOSETABLEFIELDS','edtGROUPCODE','frmNEWEDTR','COLUMNNAME~COLUMNNAME~ftString,COLUMNDESC~COLUMNDESC~ftString,','COLUMNNAME','edtGROUPCODE','COLUMNNAME','TABLENAME=\'cmfpa\'')"> <IMG SRC="#CLIENT.ICON_PATH#lookup.gif" BORDER="0" ALT="Select from Lookup" ALIGN="bottom"></A></TD>
		</TR>
		<TR height="30"><TD></TD></TR>
	  </TABLE>
		<CFMODULE TEMPLATE="#client.common_path#cfm_group.cfm" CAPTION="Applications to update">
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="50%">
		<TR height="20"><TD width="15%"></TD>
		</TR>
		<TR><TD colspan="3"><I>To select multiple entries, hold down the control key while selecting the desired entries.</I></TD></TR>
		<tr height="10"> </tr>
		<cfquery name="qryECRGDTRDTL" datasource="#client.company_dsn#">
			select *
			from ecrgdtrdtl
			where edtrcode = '#edtrcode#'
		</cfquery>
		<CFQUERY name="qryEFORMSWITHDOCNUM" datasource="#CLIENT.GLOBAL_DSN#">
			SELECT TABLENAME,count(tablename) as thecount
			FROM GRGBOSETABLEFIELDS
			WHERE COLUMNNAME = 'DOCNUMBER'
				or COLUMNNAME = 'ACTIONBY'
				or COLUMNNAME = 'DATEACTIONWASDONE'	
			group by tablename
		</CFQUERY>
		<CFQUERY name="qryEFORMSWITHACTIONBY" dbtype="query">
			SELECT TABLENAME
			FROM qryEFORMSWITHDOCNUM
				where thecount = 3
		</CFQUERY>
		<CFQUERY name="qryECRGFORMS" datasource="#CLIENT.COMPANY_DSN#">
			SELECT FORMCODE, DESCRIPTION,FORMGROUP,TABLENAME_FK
			FROM ECRGFORMS
			WHERE TABLENAME_FK <> 'ECINDTRUPDATE'
				AND TABLENAME_FK IN (#QUOTEDVALUELIST(qryEFORMSWITHACTIONBY.TABLENAME)#)
			ORDER BY DESCRIPTION
		</CFQUERY>
		<CFSET THESIZE = qryECRGFORMS.RECORDCOUNT + 1>
		<tr>
			<td></td><td width="54%"> Application </td> 
			<td width="31%">Date Field </td>
		</tr>
		<tr height="10"></tr>
		<TR>
			<TD>
				<!---<cfselect name="selEFORM" display="DESCRIPTION" multiple="yes" value="FORMCODE" query="qryECRGFORMS" validateat="onsubmit" queryPosition="below" group="FORMGROUP" SIZE="#THESIZE#" required="yes" message="Application/s to update is/are required.">
					<OPTION value="PX">Attendance Exceptions</OPTION>
				</cfselect>--->
				<cfif listfindnocase(valuelist(qryecrgdtrdtl.formcode_fk),"PX")>
				<CFINPUT type="checkbox" name="chkEFORMS" required="yes" validateat="onsubmit" value="PX" checked="yes" message="Please select at least one application.">
				<cfelse>
				<CFINPUT type="checkbox" name="chkEFORMS" required="yes" validateat="onsubmit" value="PX" message="Please select at least one application.">
				</cfif>
			</TD>
			<td valign="middle"> Attendance Exceptions </td>
			<td> N.A. </td>
		</TR>
		<CFLOOP QUERY = "qryECRGFORMS">
		<cfset arow = currentrow>
		<tr bgcolor="#IIf(CurrentRow Mod 2, "client.color_tblset1","client.color_tblset2")#" valign="top">
			<TD valign="middle">
				<!---<cfselect name="selEFORM" display="DESCRIPTION" multiple="yes" value="FORMCODE" query="qryECRGFORMS" validateat="onsubmit" queryPosition="below" group="FORMGROUP" SIZE="#THESIZE#" required="yes" message="Application/s to update is/are required.">
					<OPTION value="PX">Attendance Exceptions</OPTION>
				</cfselect>--->
				<cfif listfindnocase(valuelist(qryecrgdtrdtl.formcode_fk),formcode)>
					<CFINPUT type="checkbox" name="chkEFORMS" required="yes" validateat="onsubmit" value="#formcode#" checked="yes" message="Please select at least one application.">
				<cfelse>
					<CFINPUT type="checkbox" name="chkEFORMS" required="yes" validateat="onsubmit" value="#formcode#" message="Please select at least one application.">
				</cfif>
			</TD>
			<td valign="middle"> #description# </td>
			<CFQUERY name="getDATEFIELDS#TABLENAME_FK#" datasource="#CLIENT.GLOBAL_DSN#">
				SELECT COLUMNNAME,COLUMNDESC
				FROM GRGBOSETABLEFIELDS
				WHERE TABLENAME = '#TABLENAME_FK#'
					AND COLUMNTYPE = 'ftDateTime'
					AND COLUMNNAME NOT IN ('RECDATECREATED','DATEACTIONWASDONE')
			</CFQUERY>
			<CFQUERY name="qryECRGDTRDTLdatefield" datasource="#client.company_dsn#">
				select datefield 
				from ecrgdtrdtl
				where edtrcode = '#edtrcode#'
					and formcode_fk = '#formcode#'
			</CFQUERY>
			<td>
			<CFIF EVALUATE("getDATEFIELDS#TABLENAME_FK#.RECORDCOUNT")>
			<CFSELECT multiple="yes" name="selDATE#AROW#" value="COLUMNNAME" display="COLUMNDESC" query="getDATEFIELDS#TABLENAME_FK#"  selected="#qryECRGDTRDTLdatefield.datefield#" style="width:100%; height:100%"/>
			<CFELSE>
			N.A.
			</CFIF>
			</td>
		</TR>
		</CFLOOP>
	  </TABLE>
		<cfif saction eq "edit">
			<cfinput type="hidden" name="hidedtrcode" value="#edtrcode#">
		<cfelseif saction eq "replicate">
			<cfinput type="hidden" name="hidedtrcode" value="#createUUID()#">
		</cfif>
	</CFFORM>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="FALSE">
</CFOUTPUT>
</BODY>
</HTML>